﻿function show(tag, w, h) {
    var light = document.getElementById(tag);
    var fade = document.getElementById('fade');

    var left = (document.getElementById('main').clientWidth - w) / 2;

    light.style.left = left + 'px';
    light.style.top = 30 + 'px';

    light.className = "white_content";
    if (parseInt(w) > 0) {
        light.style.width = w + 'px';
    }
    if (parseInt(h) > 0) {
        light.style.height = h + 'px';
    }
    var childTagName = light.children[0].children[0].nodeName;
    var chardTagValue = light.children[0].children[0].innerHTML;
    if(childTagName!="A" || chardTagValue!="Close")
    {
        var divClose = document.createElement('div');
        divClose.className = "close";
        divClose.innerHTML = "<a href='javascript:void(0)' onclick='hide(\"" + tag + "\")'>X</a>";
        light.insertBefore(divClose, light.firstChild);
    }

    light.style.display = 'block';
    fade.style.display = 'block';

    overlaySize(fade);
}
function hide(tag) {
    var light = document.getElementById(tag);
    var fade = document.getElementById('fade');
    light.style.display = 'none';
    fade.style.display = 'none';
}

function overlaySize(fade) {
    fade = fade || document.getElementById('fade');
    if (window.innerHeight && window.scrollMaxY) {
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        yScroll = document.body.offsetHeight;
    }
    if (window.screen.availHeight > yScroll) {
        yScroll = window.screen.availHeight;
    }
    fade.style.height= yScroll + "px";
}
